Add workaround for Swagger UI operation id wrapping #2891
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The issue or feature being addressed
Since Swashbuckle 6.6.0 updated from Swagger UI version 4.15.5 to 5.17.9 the operation ids (which are shown if
app.UseSwaggerUI(c => c.DisplayOperationId());
is used) are wrapping even if there would be enough space. See swagger-api/swagger-ui#9577Details on the issue fix or feature implementation
The workaround works, but I'm not sure if this is the best way to fix this. This is also why I didn't create a PR for Swagger UI directly.
I'm also not sure if this should really be added to Swashbuckle. But the index.html file already contains some other workarounds, so I guess it's fine?
I've tested the fix by using the
SwaggerUIOptions.HeadContent
property. But I'd like to test it with a real Swashbuckle package too. Is there a way to get a PR build published on the MyGet feed?An alternative would be to modify the method
DisplayOperationId
instead. In there we could do this:I'm open for better ideas.